/**
\file IO.h
*/
#pragma once
#include <lostlbase.h>
#include <fstream>
#include <System.h>

namespace System { namespace Diagnostics {

	class FileVersionInfo
	{
	public:
		static FileVersionInfo GetVersionInfo(const char *fileName);
		/** Gets the comments associated with the file.*/
		string	get_Comments()				{ return get_String("Comments"); }
		/** Gets the name of the company that produced the file.*/
		string	get_CompanyName()			{ return get_String("CompanyName");}
		/** Gets the build number of the file.*/
		int		get_FileBuildPart()			{ return HIWORD(m_fileInfo->dwFileVersionLS); }
		/** Gets the description of the file. */
		string	get_FileDescription()		{ return get_String("FileDescription"); }
		/** Gets the major part of the version number. */
		int		get_FileMajorPart()			{ return HIWORD(m_fileInfo->dwFileVersionMS); }
		/** Gets the minor part of the version number of the file. */
		int		get_FileMinorPart()			{ return LOWORD(m_fileInfo->dwFileVersionMS); }
		/** Gets the name of the file that this instance of FileVersionInfo describes. */
		string	get_FileName();
		/** Gets the file private part number, a.k.a. revision number. */
		int		get_FilePrivatePart()		{ return LOWORD(m_fileInfo->dwFileVersionLS); }
		/** Gets the file version number. */
		string	get_FileVersion()			{ return get_String("FileVersion"); }
		/** Gets the internal name of the file, if one exists. */
		string	get_InternalName()			{ return get_String("InternalName"); }
		/** Gets a value that specifies whether the file contains debugging information or is compiled with debugging features enabled. */
		bool	get_IsDebug()				{ return (m_fileInfo->dwFileFlags & VS_FF_DEBUG) == VS_FF_DEBUG; }
		/** Gets a value that specifies whether the file has been modified and is not identical to the original shipping file of the same version number. */
		bool	get_IsPatched()				{ return (m_fileInfo->dwFileFlags & VS_FF_DEBUG) == VS_FF_PATCHED; }
		/** Gets a value that specifies whether the file is a development version, rather than a commercially released product. */
		bool	get_IsPreRelease()			{ return (m_fileInfo->dwFileFlags & VS_FF_DEBUG) == VS_FF_PRERELEASE; }
		/** Gets a value that specifies whether the file was built using standard release procedures. */
		bool	get_IsPrivateBuild()		{ return (m_fileInfo->dwFileFlags & VS_FF_DEBUG) == VS_FF_PRIVATEBUILD; }
		/** Gets a value that specifies whether the file is a special build. */
		bool	get_IsSpecialBuild()		{ return (m_fileInfo->dwFileFlags & VS_FF_DEBUG) == VS_FF_SPECIALBUILD; }
		/** Gets the default language string for the version info block. */
		string	get_Language();
		/** Gets all copyright notices that apply to the specified file. */
		string	get_LegalCopyright()		{ return get_String("LegalCopyright"); }
		/** Gets the trademarks and registered trademarks that apply to the file. */
		string	get_LegalTrademarks()		{ return get_String("LegalTrademarks"); }
		/** Gets the name the file was created with. */
		string	get_OriginalFilename()		{ return get_String("OriginalFilename"); }
		/** Gets information about a private version of the file. */
		string	get_PrivateBuild()			{ return get_String("PrivateBuild"); }
		/** Gets the build number of the product this file is associated with. */
		int		get_ProductBuildPart()		{ return HIWORD(m_fileInfo->dwProductVersionLS); }
		/** Gets the major part of the version number for the product this file is associated with. */
		int		get_ProductMajorPart()		{ return HIWORD(m_fileInfo->dwProductVersionMS); }
		/** Gets the minor part of the version number for the product the file is associated with. */
		int		get_ProductMinorPart()		{ return LOWORD(m_fileInfo->dwProductVersionMS); }
		/** Gets the name of the product this file is distributed with. */
		string	get_ProductName()			{ return get_String("ProductName"); }
		/** Gets the private part number of the product this file is associated with. */
		int		get_ProductPrivatePart()	{ return LOWORD(m_fileInfo->dwProductVersionLS); }
		/** Gets the version of the product this file is distributed with. */
		string	get_ProductVersion()		{ return get_String("ProductVersion"); }
		/** Gets the special build information for the file. */
		string	get_SpecialBuild()			{ return get_String("SpecialBuild"); }
		/** Gets the string */
		string	get_String(const char *label);
private:
		FileVersionInfo(const vector<unsigned char>& versionInfo);
		vector<unsigned char>	m_versionInfo;
		VS_FIXEDFILEINFO		*m_fileInfo;
		UINT					m_fixedSizeInfo;
		struct LANGANDCODEPAGE {
			WORD wLanguage;
			WORD wCodePage;
		}						*m_translate;
		UINT					m_numberOfCodePages;
	};

} }

using namespace System::Diagnostics;